using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using Volo.Abp.Domain.Entities.Auditing;
using Volo.Abp.MultiTenancy;

namespace MatrixFramework.Shared.Domain.Photos
{
    /// <summary>
    /// 照片领域实体
    /// 表示系统中的单个照片或视频文件
    /// </summary>
    public class Photo : FullAuditedAggregateRoot<Guid>, IMultiTenant
    {
        /// <summary>
        /// 租户ID
        /// </summary>
        public virtual Guid? TenantId { get; protected set; }

        /// <summary>
        /// 照片文件名
        /// </summary>
        [Required]
        [MaxLength(500)]
        public virtual string FileName { get; protected set; }

        /// <summary>
        /// 原始文件名
        /// </summary>
        [Required]
        [MaxLength(500)]
        public virtual string OriginalFileName { get; protected set; }

        /// <summary>
        /// 文件扩展名
        /// </summary>
        [Required]
        [MaxLength(50)]
        public virtual string Extension { get; protected set; }

        /// <summary>
        /// MIME类型
        /// </summary>
        [Required]
        [MaxLength(200)]
        public virtual string ContentType { get; protected set; }

        /// <summary>
        /// 文件大小（字节）
        /// </summary>
        public virtual long FileSize { get; protected set; }

        /// <summary>
        /// 文件哈希值（用于去重）
        /// </summary>
        [Required]
        [MaxLength(100)]
        public virtual string FileHash { get; protected set; }

        /// <summary>
        /// 存储路径
        /// </summary>
        [Required]
        [MaxLength(1000)]
        public virtual string StoragePath { get; protected set; }

        /// <summary>
        /// 访问URL
        /// </summary>
        [MaxLength(2000)]
        public virtual string AccessUrl { get; protected set; }

        /// <summary>
        /// 下载URL
        /// </summary>
        [MaxLength(2000)]
        public virtual string DownloadUrl { get; protected set; }

        /// <summary>
        /// 缩略图URL
        /// </summary>
        [MaxLength(2000)]
        public virtual string ThumbnailUrl { get; protected set; }

        /// <summary>
        /// 存储提供商
        /// </summary>
        public virtual StorageProvider StorageProvider { get; protected set; }

        /// <summary>
        /// 存储桶/容器名称
        /// </summary>
        [MaxLength(200)]
        public virtual string BucketName { get; protected set; }

        /// <summary>
        /// 照片标题
        /// </summary>
        [MaxLength(500)]
        public virtual string Title { get; protected set; }

        /// <summary>
        /// 照片描述
        /// </summary>
        [MaxLength(2000)]
        public virtual string Description { get; protected set; }

        /// <summary>
        /// 照片拍摄时间
        /// </summary>
        public virtual DateTime? TakenTime { get; protected set; }

        /// <summary>
        /// 照片地理位置
        /// </summary>
        public virtual GeographicLocation Location { get; protected set; }

        /// <summary>
        /// 照片标签
        /// </summary>
        public virtual List<string> Tags { get; protected set; }

        /// <summary>
        /// 照片分类
        /// </summary>
        public virtual PhotoCategory Category { get; protected set; }

        /// <summary>
        /// 照片状态
        /// </summary>
        public virtual PhotoStatus Status { get; protected set; }

        /// <summary>
        /// 是否为收藏
        /// </summary>
        public virtual bool IsFavorite { get; protected set; }

        /// <summary>
        /// 是否公开访问
        /// </summary>
        public virtual bool IsPublic { get; protected set; }

        /// <summary>
        /// 访问次数
        /// </summary>
        public virtual int AccessCount { get; protected set; }

        /// <summary>
        /// 下载次数
        /// </summary>
        public virtual int DownloadCount { get; protected set; }

        /// <summary>
        /// 分享次数
        /// </summary>
        public virtual int ShareCount { get; protected set; }

        /// <summary>
        /// 照片元数据
        /// </summary>
        public virtual PhotoMetadata Metadata { get; protected set; }

        /// <summary>
        /// 照片技术信息
        /// </summary>
        public virtual PhotoTechnicalInfo TechnicalInfo { get; protected set; }

        /// <summary>
        /// 照片AI分析结果
        /// </summary>
        public virtual PhotoAIAnalysis AIAnalysis { get; protected set; }

        /// <summary>
        /// 相册关联
        /// </summary>
        public virtual ICollection<PhotoGallery> PhotoGalleries { get; protected set; }

        /// <summary>
        /// 人脸识别结果
        /// </summary>
        public virtual ICollection<PhotoFace> Faces { get; protected set; }

        /// <summary>
        /// 照片评论
        /// </summary>
        public virtual ICollection<PhotoComment> Comments { get; protected set; }

        /// <summary>
        /// 照片分享记录
        /// </summary>
        public virtual ICollection<PhotoShare> Shares { get; protected set; }

        protected Photo()
        {
            Tags = new List<string>();
            Location = new GeographicLocation();
            Metadata = new PhotoMetadata();
            TechnicalInfo = new PhotoTechnicalInfo();
            AIAnalysis = new PhotoAIAnalysis();
            PhotoGalleries = new List<PhotoGallery>();
            Faces = new List<PhotoFace>();
            Comments = new List<PhotoComment>();
            Shares = new List<PhotoShare>();
        }

        public Photo(
            Guid id,
            string fileName,
            string originalFileName,
            string extension,
            string contentType,
            long fileSize,
            string fileHash,
            string storagePath,
            StorageProvider storageProvider,
            Guid? tenantId = null) : base(id)
        {
            FileName = fileName;
            OriginalFileName = originalFileName;
            Extension = extension;
            ContentType = contentType;
            FileSize = fileSize;
            FileHash = fileHash;
            StoragePath = storagePath;
            StorageProvider = storageProvider;
            TenantId = tenantId;

            Tags = new List<string>();
            Location = new GeographicLocation();
            Metadata = new PhotoMetadata();
            TechnicalInfo = new PhotoTechnicalInfo();
            AIAnalysis = new PhotoAIAnalysis();
            PhotoGalleries = new List<PhotoGallery>();
            Faces = new List<PhotoFace>();
            Comments = new List<PhotoComment>();
            Shares = new List<PhotoShare>();

            Status = PhotoStatus.Processing;
            Category = PhotoCategory.Other;
        }

        /// <summary>
        /// 更新基本信息
        /// </summary>
        public virtual void UpdateBasicInfo(string title, string description = null)
        {
            Title = title;
            Description = description;
        }

        /// <summary>
        /// 更新拍摄时间
        /// </summary>
        public virtual void UpdateTakenTime(DateTime? takenTime)
        {
            TakenTime = takenTime;
        }

        /// <summary>
        /// 更新地理位置
        /// </summary>
        public virtual void UpdateLocation(GeographicLocation location)
        {
            Location = location ?? new GeographicLocation();
        }

        /// <summary>
        /// 更新分类
        /// </summary>
        public virtual void UpdateCategory(PhotoCategory category)
        {
            Category = category;
        }

        /// <summary>
        /// 更新状态
        /// </summary>
        public virtual void UpdateStatus(PhotoStatus status)
        {
            Status = status;
        }

        /// <summary>
        /// 设置收藏状态
        /// </summary>
        public virtual void SetFavorite(bool isFavorite)
        {
            IsFavorite = isFavorite;
        }

        /// <summary>
        /// 设置公开访问状态
        /// </summary>
        public virtual void SetPublicAccess(bool isPublic)
        {
            IsPublic = isPublic;
        }

        /// <summary>
        /// 增加访问次数
        /// </summary>
        public virtual void IncrementAccessCount()
        {
            AccessCount++;
        }

        /// <summary>
        /// 增加下载次数
        /// </summary>
        public virtual void IncrementDownloadCount()
        {
            DownloadCount++;
        }

        /// <summary>
        /// 增加分享次数
        /// </summary>
        public virtual void IncrementShareCount()
        {
            ShareCount++;
        }

        /// <summary>
        /// 更新标签
        /// </summary>
        public virtual void UpdateTags(List<string> tags)
        {
            Tags = tags ?? new List<string>();
        }

        /// <summary>
        /// 添加标签
        /// </summary>
        public virtual void AddTag(string tag)
        {
            if (!string.IsNullOrWhiteSpace(tag) && !Tags.Contains(tag))
            {
                Tags.Add(tag);
            }
        }

        /// <summary>
        /// 移除标签
        /// </summary>
        public virtual void RemoveTag(string tag)
        {
            Tags.Remove(tag);
        }

        /// <summary>
        /// 更新元数据
        /// </summary>
        public virtual void UpdateMetadata(PhotoMetadata metadata)
        {
            Metadata = metadata ?? new PhotoMetadata();
        }

        /// <summary>
        /// 更新技术信息
        /// </summary>
        public virtual void UpdateTechnicalInfo(PhotoTechnicalInfo technicalInfo)
        {
            TechnicalInfo = technicalInfo ?? new PhotoTechnicalInfo();
        }

        /// <summary>
        /// 更新AI分析结果
        /// </summary>
        public virtual void UpdateAIAnalysis(PhotoAIAnalysis aiAnalysis)
        {
            AIAnalysis = aiAnalysis ?? new PhotoAIAnalysis();
        }

        /// <summary>
        /// 设置URL信息
        /// </summary>
        public virtual void SetUrls(string accessUrl = null, string downloadUrl = null, string thumbnailUrl = null)
        {
            AccessUrl = accessUrl;
            DownloadUrl = downloadUrl;
            ThumbnailUrl = thumbnailUrl;
        }

        /// <summary>
        /// 标记为已处理
        /// </summary>
        public virtual void MarkAsProcessed()
        {
            Status = PhotoStatus.Normal;
        }

        /// <summary>
        /// 标记为已损坏
        /// </summary>
        public virtual void MarkAsCorrupted()
        {
            Status = PhotoStatus.Corrupted;
        }

        /// <summary>
        /// 标记为已隔离
        /// </summary>
        public virtual void MarkAsQuarantined()
        {
            Status = PhotoStatus.Quarantined;
        }

        /// <summary>
        /// 检查是否可以编辑
        /// </summary>
        public virtual bool CanEdit()
        {
            return Status == PhotoStatus.Normal;
        }

        /// <summary>
        /// 检查是否可以删除
        /// </summary>
        public virtual bool CanDelete()
        {
            return Status != PhotoStatus.Deleted;
        }

        /// <summary>
        /// 检查是否可以分享
        /// </summary>
        public virtual bool CanShare()
        {
            return Status == PhotoStatus.Normal;
        }

        /// <summary>
        /// 获取主要相册ID
        /// </summary>
        public virtual Guid? GetPrimaryGalleryId()
        {
            if (PhotoGalleries.Count == 0)
                return null;

            foreach (var photoGallery in PhotoGalleries)
            {
                if (photoGallery.IsPrimary)
                    return photoGallery.GalleryId;
            }

            return PhotoGalleries[0].GalleryId;
        }
    }

    /// <summary>
    /// 存储提供商枚举
    /// </summary>
    public enum StorageProvider
    {
        /// <summary>
        /// 本地存储
        /// </summary>
        Local = 0,

        /// <summary>
        /// MinIO
        /// </summary>
        MinIO = 1,

        /// <summary>
        /// 阿里云OSS
        /// </summary>
        AliyunOSS = 2,

        /// <summary>
        /// 腾讯云COS
        /// </summary>
        TencentCOS = 3,

        /// <summary>
        /// AWS S3
        /// </summary>
        AWSS3 = 4,

        /// <summary>
        /// Azure Blob Storage
        /// </summary>
        AzureBlob = 5
    }

    /// <summary>
    /// 照片分类枚举
    /// </summary>
    public enum PhotoCategory
    {
        /// <summary>
        /// 其他
        /// </summary>
        Other = 0,

        /// <summary>
        /// 人物照片
        /// </summary>
        People = 1,

        /// <summary>
        /// 风景照片
        /// </summary>
        Landscape = 2,

        /// <summary>
        /// 建筑照片
        /// </summary>
        Architecture = 3,

        /// <summary>
        /// 美食照片
        /// </summary>
        Food = 4,

        /// <summary>
        /// 动物照片
        /// </summary>
        Animal = 5,

        /// <summary>
        /// 植物照片
        /// </summary>
        Plant = 6,

        /// <summary>
        /// 文档照片
        /// </summary>
        Document = 7,

        /// <summary>
        /// 截图
        /// </summary>
        Screenshot = 8,

        /// <summary>
        /// 艺术作品
        /// </summary>
        Art = 9,

        /// <summary>
        /// 运动照片
        /// </summary>
        Sports = 10,

        /// <summary>
        /// 旅行照片
        /// </summary>
        Travel = 11,

        /// <summary>
        /// 家庭照片
        /// </summary>
        Family = 12,

        /// <summary>
        /// 工作照片
        /// </summary>
        Work = 13,

        /// <summary>
        /// 工程照片
        /// </summary>
        Engineering = 14
    }

    /// <summary>
    /// 照片状态枚举
    /// </summary>
    public enum PhotoStatus
    {
        /// <summary>
        /// 正常
        /// </summary>
        Normal = 0,

        /// <summary>
        /// 处理中
        /// </summary>
        Processing = 1,

        /// <summary>
        /// 已损坏
        /// </summary>
        Corrupted = 2,

        /// <summary>
        /// 已隔离
        /// </summary>
        Quarantined = 3,

        /// <summary>
        /// 已删除
        /// </summary>
        Deleted = 4,

        /// <summary>
        /// 已归档
        /// </summary>
        Archived = 5
    }

    /// <summary>
    /// 地理位置信息
    /// </summary>
    public class GeographicLocation
    {
        /// <summary>
        /// 纬度
        /// </summary>
        public double? Latitude { get; set; }

        /// <summary>
        /// 经度
        /// </summary>
        public double? Longitude { get; set; }

        /// <summary>
        /// 海拔高度（米）
        /// </summary>
        public double? Altitude { get; set; }

        /// <summary>
        /// 精度（米）
        /// </summary>
        public double? Accuracy { get; set; }

        /// <summary>
        /// 国家
        /// </summary>
        [MaxLength(100)]
        public string Country { get; set; }

        /// <summary>
        /// 省份/州
        /// </summary>
        [MaxLength(100)]
        public string Province { get; set; }

        /// <summary>
        /// 城市
        /// </summary>
        [MaxLength(100)]
        public string City { get; set; }

        /// <summary>
        /// 区县
        /// </summary>
        [MaxLength(100)]
        public string District { get; set; }

        /// <summary>
        /// 详细地址
        /// </summary>
        [MaxLength(500)]
        public string Address { get; set; }

        /// <summary>
        /// 地点名称
        /// </summary>
        [MaxLength(200)]
        public string PlaceName { get; set; }

        /// <summary>
        /// 是否有地理位置信息
        /// </summary>
        public bool HasLocation => Latitude.HasValue && Longitude.HasValue;
    }

    /// <summary>
    /// 照片元数据
    /// </summary>
    public class PhotoMetadata
    {
        /// <summary>
        /// 相机品牌
        /// </summary>
        [MaxLength(100)]
        public string CameraMake { get; set; }

        /// <summary>
        /// 相机型号
        /// </summary>
        [MaxLength(200)]
        public string CameraModel { get; set; }

        /// <summary>
        /// 镜头型号
        /// </summary>
        [MaxLength(200)]
        public string LensModel { get; set; }

        /// <summary>
        /// 拍摄参数
        /// </summary>
        public PhotoShootingParameters ShootingParameters { get; set; } = new();

        /// <summary>
        /// 图像处理信息
        /// </summary>
        public ImageProcessingInfo ProcessingInfo { get; set; } = new();

        /// <summary>
        /// 设备信息
        /// </summary>
        public DeviceInfo DeviceInfo { get; set; } = new();

        /// <summary>
        /// 软件信息
        /// </summary>
        public SoftwareInfo SoftwareInfo { get; set; } = new();

        /// <summary>
        /// 颜色信息
        /// </summary>
        public ColorInfo ColorInfo { get; set; } = new();

        /// <summary>
        /// 自定义元数据
        /// </summary>
        public Dictionary<string, object> CustomMetadata { get; set; } = new();
    }

    /// <summary>
    /// 拍摄参数
    /// </summary>
    public class PhotoShootingParameters
    {
        /// <summary>
        /// 光圈值
        /// </summary>
        public double? Aperture { get; set; }

        /// <summary>
        /// 快门速度（秒）
        /// </summary>
        public double? ShutterSpeed { get; set; }

        /// <summary>
        /// ISO感光度
        /// </summary>
        public int? ISO { get; set; }

        /// <summary>
        /// 焦距（毫米）
        /// </summary>
        public double? FocalLength { get; set; }

        /// <summary>
        /// 曝光补偿
        /// </summary>
        public double? ExposureCompensation { get; set; }

        /// <summary>
        /// 测光模式
        /// </summary>
        [MaxLength(50)]
        public string MeteringMode { get; set; }

        /// <summary>
        /// 曝光模式
        /// </summary>
        [MaxLength(50)]
        public string ExposureMode { get; set; }

        /// <summary>
        /// 白平衡模式
        /// </summary>
        [MaxLength(50)]
        public string WhiteBalance { get; set; }

        /// <summary>
        /// 闪光灯模式
        /// </summary>
        [MaxLength(50)]
        public string FlashMode { get; set; }

        /// <summary>
        /// 驱动模式
        /// </summary>
        [MaxLength(50)]
        public string DriveMode { get; set; }

        /// <summary>
        /// 焦点距离
        /// </summary>
        public double? FocusDistance { get; set; }
    }

    /// <summary>
    /// 图像处理信息
    /// </summary>
    public class ImageProcessingInfo
    {
        /// <summary>
        /// 是否经过处理
        /// </summary>
        public bool IsProcessed { get; set; }

        /// <summary>
        /// 处理软件
        /// </summary>
        [MaxLength(200)]
        public string ProcessingSoftware { get; set; }

        /// <summary>
        /// 是否经过裁剪
        /// </summary>
        public bool IsCropped { get; set; }

        /// <summary>
        /// 是否经过调整
        /// </summary>
        public bool IsAdjusted { get; set; }

        /// <summary>
        /// 色彩空间
        /// </summary>
        [MaxLength(50)]
        public string ColorSpace { get; set; }

        /// <summary>
        /// 压缩质量
        /// </summary>
        public int? CompressionQuality { get; set; }

        /// <summary>
        /// 锐化程度
        /// </summary>
        public int? Sharpening { get; set; }

        /// <summary>
        /// 对比度调整
        /// </summary>
        public int? ContrastAdjustment { get; set; }

        /// <summary>
        /// 亮度调整
        /// </summary>
        public int? BrightnessAdjustment { get; set; }

        /// <summary>
        /// 饱和度调整
        /// </summary>
        public int? SaturationAdjustment { get; set; }
    }

    /// <summary>
    /// 设备信息
    /// </summary>
    public class DeviceInfo
    {
        /// <summary>
        /// 设备类型
        /// </summary>
        [MaxLength(50)]
        public string DeviceType { get; set; }

        /// <summary>
        /// 操作系统
        /// </summary>
        [MaxLength(100)]
        public string OperatingSystem { get; set; }

        /// <summary>
        /// 应用程序
        /// </summary>
        [MaxLength(200)]
        public string Application { get; set; }

        /// <summary>
        /// 设备唯一标识
        /// </summary>
        [MaxLength(200)]
        public string DeviceId { get; set; }

        /// <summary>
        /// 制造商
        /// </summary>
        [MaxLength(100)]
        public string Manufacturer { get; set; }

        /// <summary>
        /// 序列号
        /// </summary>
        [MaxLength(100)]
        public string SerialNumber { get; set; }
    }

    /// <summary>
    /// 软件信息
    /// </summary>
    public class SoftwareInfo
    {
        /// <summary>
        /// 创建软件
        /// </summary>
        [MaxLength(200)]
        public string CreationSoftware { get; set; }

        /// <summary>
        /// 编辑软件
        /// </summary>
        [MaxLength(200)]
        public string EditingSoftware { get; set; }

        /// <summary>
        /// 软件版本
        /// </summary>
        [MaxLength(50)]
        public string SoftwareVersion { get; set; }

        /// <summary>
        /// EXIF版本
        /// </summary>
        [MaxLength(20)]
        public string ExifVersion { get; set; }

        /// <summary>
        /// IPTC版本
        /// </summary>
        [MaxLength(20)]
        public string IptcVersion { get; set; }
    }

    /// <summary>
    /// 颜色信息
    /// </summary>
    public class ColorInfo
    {
        /// <summary>
        /// 主要颜色
        /// </summary>
        public List<string> DominantColors { get; set; } = new();

        /// <summary>
        /// 色调分布
        /// </summary>
        public Dictionary<string, double> HueDistribution { get; set; } = new();

        /// <summary>
        /// 亮度分布
        /// </summary>
        public Dictionary<string, double> BrightnessDistribution { get; set; } = new();

        /// <summary>
        /// 饱和度分布
        /// </summary>
        public Dictionary<string, double> SaturationDistribution { get; set; } = new();

        /// <summary>
        /// 平均色调
        /// </summary>
        public double? AverageHue { get; set; }

        /// <summary>
        /// 平均亮度
        /// </summary>
        public double? AverageBrightness { get; set; }

        /// <summary>
        /// 平均饱和度
        /// </summary>
        public double? AverageSaturation { get; set; }
    }

    /// <summary>
    /// 照片技术信息
    /// </summary>
    public class PhotoTechnicalInfo
    {
        /// <summary>
        /// 图像宽度
        /// </summary>
        public int Width { get; set; }

        /// <summary>
        /// 图像高度
        /// </summary>
        public int Height { get; set; }

        /// <summary>
        /// 像素总数
        /// </summary>
        public long TotalPixels => Width * Height;

        /// <summary>
        /// 宽高比
        /// </summary>
        public double AspectRatio => Height > 0 ? (double)Width / Height : 0;

        /// <summary>
        /// 颜色深度
        /// </summary>
        public int ColorDepth { get; set; }

        /// <summary>
        /// 颜色通道数
        /// </summary>
        public int ColorChannels { get; set; }

        /// <summary>
        /// 压缩格式
        /// </summary>
        [MaxLength(50)]
        public string CompressionFormat { get; set; }

        /// <summary>
        /// 图像格式
        /// </summary>
        [MaxLength(20)]
        public string ImageFormat { get; set; }

        /// <summary>
        /// 文件类型
        /// </summary>
        [MaxLength(50)]
        public string FileType { get; set; }

        /// <summary>
        /// 是否有透明通道
        /// </summary>
        public bool HasAlphaChannel { get; set; }

        /// <summary>
        /// 是否为渐进式JPEG
        /// </summary>
        public bool IsProgressive { get; set; }

        /// <summary>
        /// DPI分辨率
        /// </summary>
        public int Dpi { get; set; }

        /// <summary>
        /// 分辨率单位
        /// </summary>
        [MaxLength(20)]
        public string ResolutionUnit { get; set; }
    }

    /// <summary>
    /// 照片AI分析结果
    /// </summary>
    public class PhotoAIAnalysis
    {
        /// <summary>
        /// 分析时间
        /// </summary>
        public DateTime AnalysisTime { get; set; } = DateTime.Now;

        /// <summary>
        /// 分析版本
        /// </summary>
        [MaxLength(50)]
        public string AnalysisVersion { get; set; }

        /// <summary>
        /// 场景识别结果
        /// </summary>
        public List<SceneRecognitionResult> SceneRecognition { get; set; } = new();

        /// <summary>
        /// 物体识别结果
        /// </summary>
        public List<ObjectRecognitionResult> ObjectRecognition { get; set; } = new();

        /// <summary>
        /// 文字识别结果
        /// </summary>
        public List<TextRecognitionResult> TextRecognition { get; set; } = new();

        /// <summary>
        /// 图像质量评估
        /// </summary>
        public ImageQualityAssessment QualityAssessment { get; set; } = new();

        /// <summary>
        /// 美学评分
        /// </summary>
        public AestheticScore AestheticScore { get; set; } = new();

        /// <summary>
        /// 相似照片
        /// </summary>
        public List<SimilarPhoto> SimilarPhotos { get; set; } = new();

        /// <summary>
        /// AI生成的标签
        /// </summary>
        public List<string> AITags { get; set; } = new();

        /// <summary>
        /// 置信度分数
        /// </summary>
        public double ConfidenceScore { get; set; }

        /// <summary>
        /// 是否需要人工审核
        /// </summary>
        public bool RequiresManualReview { get; set; }
    }

    /// <summary>
    /// 场景识别结果
    /// </summary>
    public class SceneRecognitionResult
    {
        /// <summary>
        /// 场景名称
        /// </summary>
        public string SceneName { get; set; }

        /// <summary>
        /// 置信度
        /// </summary>
        public double Confidence { get; set; }

        /// <summary>
        /// 场景分类
        /// </summary>
        public string Category { get; set; }

        /// <summary>
        /// 边界框坐标
        /// </summary>
        public BoundingBox BoundingBox { get; set; }
    }

    /// <summary>
    /// 物体识别结果
    /// </summary>
    public class ObjectRecognitionResult
    {
        /// <summary>
        /// 物体名称
        /// </summary>
        public string ObjectName { get; set; }

        /// <summary>
        /// 置信度
        /// </summary>
        public double Confidence { get; set; }

        /// <summary>
        /// 物体类别
        /// </summary>
        public string Category { get; set; }

        /// <summary>
        /// 边界框坐标
        /// </summary>
        public BoundingBox BoundingBox { get; set; }

        /// <summary>
        /// 物体属性
        /// </summary>
        public Dictionary<string, object> Attributes { get; set; } = new();
    }

    /// <summary>
    /// 文字识别结果
    /// </summary>
    public class TextRecognitionResult
    {
        /// <summary>
        /// 识别的文字
        /// </summary>
        public string Text { get; set; }

        /// <summary>
        /// 置信度
        /// </summary>
        public double Confidence { get; set; }

        /// <summary>
        /// 语言类型
        /// </summary>
        public string Language { get; set; }

        /// <summary>
        /// 边界框坐标
        /// </summary>
        public BoundingBox BoundingBox { get; set; }

        /// <summary>
        /// 文字类型
        /// </summary>
        public string TextType { get; set; } // 手写、印刷等
    }

    /// <summary>
    /// 图像质量评估
    /// </summary>
    public class ImageQualityAssessment
    {
        /// <summary>
        /// 整体质量评分（0-100）
        /// </summary>
        public double OverallScore { get; set; }

        /// <summary>
        /// 清晰度评分
        /// </summary>
        public double SharpnessScore { get; set; }

        /// <summary>
        /// 噪点评分
        /// </summary>
        public double NoiseScore { get; set; }

        /// <summary>
        /// 曝光评分
        /// </summary>
        public double ExposureScore { get; set; }

        /// <summary>
        /// 对焦评分
        /// </summary>
        public double FocusScore { get; set; }

        /// <summary>
        /// 色彩评分
        /// </summary>
        public double ColorScore { get; set; }

        /// <summary>
        /// 构图评分
        /// </summary>
        public double CompositionScore { get; set; }

        /// <summary>
        /// 质量等级
        /// </summary>
        public QualityGrade QualityGrade { get; set; }
    }

    /// <summary>
    /// 质量等级
    /// </summary>
    public enum QualityGrade
    {
        /// <summary>
        /// 优秀
        /// </summary>
        Excellent = 0,

        /// <summary>
        /// 良好
        /// </summary>
        Good = 1,

        /// <summary>
        /// 一般
        /// </summary>
        Fair = 2,

        /// <summary>
        /// 较差
        /// </summary>
        Poor = 3,

        /// <summary>
        /// 很差
        /// </summary>
        VeryPoor = 4
    }

    /// <summary>
    /// 美学评分
    /// </summary>
    public class AestheticScore
    {
        /// <summary>
        /// 整体美学评分（0-100）
        /// </summary>
        public double OverallScore { get; set; }

        /// <summary>
        /// 构图评分
        /// </summary>
        public double CompositionScore { get; set; }

        /// <summary>
        /// 色彩和谐度评分
        /// </summary>
        public double ColorHarmonyScore { get; set; }

        /// <summary>
        /// 视觉吸引力评分
        /// </summary>
        public double VisualAppealScore { get; set; }

        /// <summary>
        /// 情感冲击力评分
        /// </summary>
        public double EmotionalImpactScore { get; set; }

        /// <summary>
        /// 美学等级
        /// </summary>
        public AestheticGrade Grade { get; set; }
    }

    /// <summary>
    /// 美学等级
    /// </summary>
    public enum AestheticGrade
    {
        /// <summary>
        /// 杰作级
        /// </summary>
        Masterpiece = 0,

        /// <summary>
        /// 优秀级
        /// </summary>
        Excellent = 1,

        /// <summary>
        /// 良好级
        /// </summary>
        Good = 2,

        /// <summary>
        /// 一般级
        /// </summary>
        Average = 3,

        /// <summary>
        /// 待改进
        /// </summary>
        NeedsImprovement = 4
    }

    /// <summary>
    /// 相似照片
    /// </summary>
    public class SimilarPhoto
    {
        /// <summary>
        /// 相似照片ID
        /// </summary>
        public Guid PhotoId { get; set; }

        /// <summary>
        /// 相似度分数（0-1）
        /// </summary>
        public double SimilarityScore { get; set; }

        /// <summary>
        /// 相似类型
        /// </summary>
        public SimilarityType SimilarityType { get; set; }

        /// <summary>
        /// 匹配区域
        /// </summary>
        public List<MatchingRegion> MatchingRegions { get; set; } = new();
    }

    /// <summary>
    /// 相似类型
    /// </summary>
    public enum SimilarityType
    {
        /// <summary>
        /// 完全相同
        /// </summary>
        Identical = 0,

        /// <summary>
        /// 近似重复
        /// </summary>
        NearDuplicate = 1,

        /// <summary>
        /// 相似内容
        /// </summary>
        SimilarContent = 2,

        /// <summary>
        /// 相似场景
        /// </summary>
        SimilarScene = 3,

        /// <summary>
        /// 相似构图
        /// </summary>
        SimilarComposition = 4
    }

    /// <summary>
    /// 匹配区域
    /// </summary>
    public class MatchingRegion
    {
        /// <summary>
        /// 源图像边界框
        /// </summary>
        public BoundingBox SourceBox { get; set; }

        /// <summary>
        /// 目标图像边界框
        /// </summary>
        public BoundingBox TargetBox { get; set; }

        /// <summary>
        /// 区域相似度
        /// </summary>
        public double RegionSimilarity { get; set; }
    }

    /// <summary>
    /// 边界框
    /// </summary>
    public class BoundingBox
    {
        /// <summary>
        /// X坐标
        /// </summary>
        public double X { get; set; }

        /// <summary>
        /// Y坐标
        /// </summary>
        public double Y { get; set; }

        /// <summary>
        /// 宽度
        /// </summary>
        public double Width { get; set; }

        /// <summary>
        /// 高度
        /// </summary>
        public double Height { get; set; }

        /// <summary>
        /// 置信度
        /// </summary>
        public double Confidence { get; set; }
    }
}